Common.hlsl 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef _INCLUDE_JP_KEIJIRO_NOISESHADER_COMMON_HLSL_
  2. #define _INCLUDE_JP_KEIJIRO_NOISESHADER_COMMON_HLSL_
  3. float wglnoise_mod(float x, float y)
  4. {
  5. return x - y * floor(x / y);
  6. }
  7. float2 wglnoise_mod(float2 x, float2 y)
  8. {
  9. return x - y * floor(x / y);
  10. }
  11. float3 wglnoise_mod(float3 x, float3 y)
  12. {
  13. return x - y * floor(x / y);
  14. }
  15. float4 wglnoise_mod(float4 x, float4 y)
  16. {
  17. return x - y * floor(x / y);
  18. }
  19. float2 wglnoise_fade(float2 t)
  20. {
  21. return t * t * t * (t * (t * 6 - 15) + 10);
  22. }
  23. float3 wglnoise_fade(float3 t)
  24. {
  25. return t * t * t * (t * (t * 6 - 15) + 10);
  26. }
  27. float wglnoise_mod289(float x)
  28. {
  29. return x - floor(x / 289) * 289;
  30. }
  31. float2 wglnoise_mod289(float2 x)
  32. {
  33. return x - floor(x / 289) * 289;
  34. }
  35. float3 wglnoise_mod289(float3 x)
  36. {
  37. return x - floor(x / 289) * 289;
  38. }
  39. float4 wglnoise_mod289(float4 x)
  40. {
  41. return x - floor(x / 289) * 289;
  42. }
  43. float3 wglnoise_permute(float3 x)
  44. {
  45. return wglnoise_mod289((x * 34 + 1) * x);
  46. }
  47. float4 wglnoise_permute(float4 x)
  48. {
  49. return wglnoise_mod289((x * 34 + 1) * x);
  50. }
  51. #endif